<%@ include file="/WEB-INF/common/taglibs.jsp" %>
<head><style>
<link href="${supr}/plugins/forms/validate/validate.css" type="text/css" rel="stylesheet" />
</style></head>

<!-- loading animation -->
<div id="qLoverlay">
</div>
<div id="qLbar">
</div>
<div id="header">
	<div class="navbar">
		<div class="navbar-inner">
			<div class="container-fluid">
				<a class="brand" href="${ctx}/admin/dashboard/"><span class="blue">CMS.</span><span class="slogan">admin</span></a>
				<div class="nav-no-collapse">
					<ul class="nav">
						<li><a href="${ctx}/admin/dashboard/"><span class="icon16 icomoon-icon-screen-2"></span> Dashboard</a></li>
						<li class="dropdown">
						<a href="#" class="dropdown-toggle" data-toggle="dropdown">
						<span class="icon16 icomoon-icon-cog"></span> Settings <b class="caret"></b>
						</a>
						<ul class="dropdown-menu">
							<li class="menu">
							<ul>
								<li>
								<a href="#" id="siteConfigModel"><span class="icon16 icomoon-icon-equalizer"></span>Site config</a>
								</li>
								<li>
								<a href="#"><span class="icon16 icomoon-icon-wrench"></span>Plugins</a>
								</li>
								<li>
								<a href="#"><span class="icon16 icomoon-icon-picture-2"></span>Themes</a>
								</li>
							</ul>
							</li>
						</ul>
						</li>
						<li><a href="#" id="viewIndex"><span class="icon16 icomoon-icon-basket"></span> My Webside</a></li>
					</ul>
					<ul class="nav pull-right usernav">
						<li class="dropdown">
						<a href="#" class="dropdown-toggle" data-toggle="dropdown">
						<span class="icon16 icomoon-icon-bell-2"></span>
						</a>
						<ul class="dropdown-menu">
							<li class="menu">
							<ul class="notif">
								<li class="header"><strong>Notifications</strong> (0) items</li>
							</ul>
							</li>
						</ul>
						</li>
						<li class="dropdown">
						<a href="#" class="dropdown-toggle avatar" data-toggle="dropdown">
						<img src="${supr}/images/avatar.png" alt="" class="image"/>
						<span class="txt">Welcome</span>
						<b class="caret"></b>
						</a>
						<ul class="dropdown-menu">
							<li class="menu">
							<ul>
								<li>
								<a href="#changePassword" data-toggle="modal"><span class="icon16 icomoon-icon-user-3"></span>Change Password</a>
								</li>
								<li>
								<a href="#changeEmail"  data-toggle="modal"><span class="icon16 icomoon-icon-comments-2"></span>Change Email</a>
								</li>
							</ul>
							</li>
						</ul>
						</li>
						<li>
						<a href="${ctx}/admin/logout/"><span class="icon16 icomoon-icon-exit"></span> Logout</a>
						</li>
					</ul>
				</div>
				<!-- /.nav-collapse -->
			</div>
		</div>
		<!-- /navbar-inner -->
	</div>
	<!-- /navbar -->
</div>
<!-- End #header -->

<div id="changePassword" class="modal hide fade" style="display: none; ">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal">
			<span class="icon12 minia-icon-close"></span>
		</button>
		<h3>Change password </h3>
	</div>
	<div class="modal-body">
 				<form method="post" id="pwdForm">
						<div class="form-row row-fluid">
							<label class="form-label span4">Old Password</label>
							<input class="span8" name="odPassword" type="password" />
						</div>
						<div class="form-row row-fluid">
							<label class="form-label span4">Password</label>
							<input class="span8" name="password" type="password" />
						</div>
						<div class="form-row row-fluid">
							<label class="form-label span4">Confirm Password</label>
							<input class="span8" name="cfPassword" type="Password" />
						</div>

				</form>

	</div>
	<div class="modal-footer">
		<a href="#" class="btn" data-dismiss="modal">Close</a>
		<a href="#" id ="confirmPwd" class="btn btn-primary">Save changes</a>
	</div>
</div>

<div id="changeEmail" class="modal hide fade" style="display: none; ">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal">
			<span class="icon12 minia-icon-close"></span>
		</button>
		<h3>Change Email </h3>
	</div>
	<div class="modal-body">
 				<form method="post" id="emailForm">
						<div class="form-row row-fluid">
							<label class="form-label span4">New Email address</label>
							<input class="span8" name="email" />
						</div>
				</form>

	</div>
	<div class="modal-footer">
		<a href="#" class="btn" data-dismiss="modal">Close</a>
		<a href="#" id ="confirmEmail" class="btn btn-primary">Save changes</a>
	</div>
</div>

<script type="text/javascript" src="${supr}/plugins/forms/validate/jquery.validate.min.js"></script>
 
<script>
$(document).ready(function () {
	$('#modal').dialog({
		autoOpen: false,
		modal: true,
		dialogClass: 'dialog',
		buttons: {
			"Close": function() { 
				$(this).dialog("close"); 
			}
		}
	});

	$('#confirmPwd').click(function(){
	 
		$.ajax({
			url : "${ctx}/user/activity/changepwd/",
			type : "PUT",
			data : $('#pwdForm').serialize(),
			dataType : "json",
			success : function(data){		
				if(data && data.state && (data.state.indexOf("ERROR") != -1)){
					johnny.error(data.message);
					return;
				}else{
					$("#changePassword").modal('hide');
					johnny.info("update password successfully");
					}
			}
		});


	});
	$('#confirmEmail').click(function(){
		 
		$.ajax({
			url : "${ctx}/user/activity/changeEmail/",
			type : "PUT",
			data : $('#emailForm').serialize(),
			dataType : "json",
			success : function(data){		
				if(data && data.state && (data.state.indexOf("ERROR") != -1)){
					johnny.error(data.message);
					return;
				}else{

					$("#changeEmail").modal('hide');
					johnny.info("update email successfully");
					}
			}
		});


	});
	
	$('#changePassword').modal({ show: false});
    $("#viewIndex").click(function () {
    	var viewOrderUrl = mnc.ctx + "/";
        window.open(viewOrderUrl, "View Index", "scrollbars=no,toolbar=no,menubar=no,resizable=yes");
    });
});
</script>
